package com.skynet.supervision.utils.functional;

import java.util.function.Predicate;

@FunctionalInterface
public interface ThrowablePredicate<T, E extends Throwable> {
    boolean test(T t) throws E;

    default Predicate<T> toPredicate() {
        return v -> {
            try {
                return ThrowablePredicate.this.test(v);
            } catch (Throwable t) {
                FuncUtils.uncheckedThrow(t);
            }
            throw new RuntimeException("unreachable");
        };
    }

}


